//auto gen by paipai.java.augogen ver 154
//author floatman
#ifndef _ACCOUNTDAO_ACCOUNT_H_
#define _ACCOUNTDAO_ACCOUNT_H_

#include <stdint.h>
#include <string>
#include <iostream>
#include "app_platform/help_macros.h"
#include "app_platform/intf_service.h"
#include "intf_accountdao.h"

#include "library/basic/singleton_t.h"
#include "library/basic/sync_lock.h"
#include "c2cent/library/log/CWTimeElf3.h"

#include <vector>
#include <set>
#include <map>
#include "erp/account/ddo/businessunitsfilterddo_account.h"
#include "erp/account/ddo/businessunitsddo_account.h"
#include "erp/account/ddo/contactfilterddo_account.h"
#include "erp/account/ddo/contactddo_account.h"
#include "erp/account/ddo/customercreditddo_account.h"
#include "erp/account/ddo/employeefilterddo_account.h"
#include "erp/account/ddo/employeeddo_account.h"

HEADER_SELF_DEFINE_START
/**
*  请在这里增加自定义包含的头文件，否则无法合并代码
**/

#include "account_db_operator.h"
#include "erp/comm/erp_yun_define.h"
#include "c2cent/dao/idmaker/idmakerdao_stub4web_allinone.h"
using namespace erp::yun::comm;

HEADER_SELF_DEFINE_END

namespace erp
{
namespace account
{
namespace dao
{

#define ACCOUNTDAO_SERVICE_VERSION "ERP_ACCOUNT_DAO___ACCOUNTDAO__SERVICE_VERSION__1.0 2013-10-29 18:53:29"
const std::string ACCOUNTDAO_SERVICE_NOUSE = ACCOUNTDAO_SERVICE_VERSION;

SERVICE class CAccountDao : public IAccountDao{
public:
		CAccountDao(enum DeployMethod method = DEPLOY_STANDALONE);
		~CAccountDao();
		 void Reset();
		static int Initialize(IUserDefineCntl* pCntl = NULL);

public:
	 /**
	 *
	 *   添加/修改来往单位；传入来往单位SysNo不为0时则进行修改，反之则进行添加；
	 *
	 */
	EXPORT(0xc0381801) uint32_t ModifyBusinessUnits(
		 const CCntlInfo& rCntlInfo,
		 const std::string& strMachineKey,
		 const std::string& strSource,
		 uint32_t dwSceneId,
		 uint32_t dwOption,
		 const erp::account::ddo::CBusinessUnitsDdo& oBusinessUnitsDdo,
		 const std::string& strInReserve,
		 std::string& strErrmsg,
		 uint64_t& ddwSysNo,
		 std::string& strOutReserve
		);

	 /**
	 *
	 *   删除来往单位（逻辑）
	 *
	 */
	EXPORT(0xc0381802) uint32_t DeleteBusinessUnits(
		 const CCntlInfo& rCntlInfo,
		 const std::string& strMachineKey,
		 const std::string& strSource,
		 uint32_t dwSceneId,
		 uint32_t dwOption,
		 uint64_t ddwBusinessUnitsSysNo,
		 const std::string& strInReserve,
		 std::string& strErrmsg,
		 std::string& strOutReserve
		);

	 /**
	 *
	 *   根据分支机构ID批量获取分支机构信息
	 *
	 */
	EXPORT(0xc0381803) uint32_t GetBusinessUnitsBySysNos(
		 const CCntlInfo& rCntlInfo,
		 const std::string& strMachineKey,
		 const std::string& strSource,
		 uint32_t dwSceneId,
		 uint32_t dwOption,
		 const std::set<uint64_t> & setBusinessUnitsSysNo,
		 const std::string& strInReserve,
		 std::string& strErrmsg,
		 std::map<uint64_t,uint32_t> & mapErrorCode,
		 std::map<uint64_t,std::string> & mapErrorMsg,
		 std::map<uint64_t,erp::account::ddo::CBusinessUnitsDdo> & mapBusinessUnitsDdo,
		 std::string& strOutReserve
		);

	 /**
	 *
	 *   根据过滤条件查询来往单位列表信息
	 *
	 */
	EXPORT(0xc0381804) uint32_t GetBusinessUnitsByFilter(
		 const CCntlInfo& rCntlInfo,
		 const std::string& strMachineKey,
		 const std::string& strSource,
		 uint32_t dwSceneId,
		 uint32_t dwOption,
		 const erp::account::ddo::CBusinessUnitsFilterDdo& oFilter,
		 const std::string& strInReserve,
		 std::string& strErrmsg,
		 uint32_t& dwTotal,
		 std::vector<erp::account::ddo::CBusinessUnitsDdo> & vecBusinessUnitsDdo,
		 std::string& strOutReserve
		);

	 /**
	 *
	 *   添加/修改职员；传入来往单位SysNo不为0时则进行修改，反之则进行添加；
	 *
	 */
	EXPORT(0xc0381805) uint32_t ModifyEmployee(
		 const CCntlInfo& rCntlInfo,
		 const std::string& strMachineKey,
		 const std::string& strSource,
		 uint32_t dwSceneId,
		 uint32_t dwOption,
		 const erp::account::ddo::CEmployeeDdo& oEmployeeDdo,
		 const std::string& strInReserve,
		 std::string& strErrmsg,
		 uint64_t& ddwSysNo,
		 std::string& strOutReserve
		);

	 /**
	 *
	 *   删除职员（逻辑）
	 *
	 */
	EXPORT(0xc0381806) uint32_t DeleteEmployee(
		 const CCntlInfo& rCntlInfo,
		 const std::string& strMachineKey,
		 const std::string& strSource,
		 uint32_t dwSceneId,
		 uint32_t dwOption,
		 uint64_t ddwEmployeeSysNo,
		 const std::string& strInReserve,
		 std::string& strErrmsg,
		 std::string& strOutReserve
		);

	 /**
	 *
	 *   根据职员ID批量获取职员信息
	 *
	 */
	EXPORT(0xc0381807) uint32_t GetEmployeeBySysNos(
		 const CCntlInfo& rCntlInfo,
		 const std::string& strMachineKey,
		 const std::string& strSource,
		 uint32_t dwSceneId,
		 uint32_t dwOption,
		 const std::set<uint64_t> & setEmployeeSysNo,
		 const std::string& strInReserve,
		 std::string& strErrmsg,
		 std::map<uint64_t,uint32_t> & mapErrorCode,
		 std::map<uint64_t,std::string> & mapErrorMsg,
		 std::map<uint64_t,erp::account::ddo::CEmployeeDdo> & mapEmployeeDdo,
		 std::string& strOutReserve
		);

	 /**
	 *
	 *   根据过滤条件查询职员列表信息
	 *
	 */
	EXPORT(0xc0381808) uint32_t GetEmployeeByFilter(
		 const CCntlInfo& rCntlInfo,
		 const std::string& strMachineKey,
		 const std::string& strSource,
		 uint32_t dwSceneId,
		 uint32_t dwOption,
		 const erp::account::ddo::CEmployeeFilterDdo& oFilter,
		 const std::string& strInReserve,
		 std::string& strErrmsg,
		 uint32_t& dwTotal,
		 std::vector<erp::account::ddo::CEmployeeDdo> & vecBusinessUnitsDdo,
		 std::string& strOutReserve
		);

	 /**
	 *
	 *   根据主键查询信用额度
	 *
	 */
	EXPORT(0xc0381809) uint32_t GetCustomerCredit(
		 const CCntlInfo& rCntlInfo,
		 const std::string& strMachineKey,
		 const std::string& strSource,
		 uint32_t dwSceneId,
		 uint32_t dwOption,
		 uint64_t ddwBranchSysNo,
		 uint64_t ddwBusinessUnitsSysNo,
		 const std::string& strInReserve,
		 std::string& strErrmsg,
		 erp::account::ddo::CCustomerCreditDdo& oCustomerCreditDdo,
		 std::string& strOutReserve
		);

	 /**
	 *
	 *   添加/修改信用额度；传入组合主键往来单位SysNo和分支机构SysNo
	 *
	 */
	EXPORT(0xc038180a) uint32_t ModifyCustomerCredit(
		 const CCntlInfo& rCntlInfo,
		 const std::string& strMachineKey,
		 const std::string& strSource,
		 uint32_t dwSceneId,
		 uint32_t dwOption,
		 const erp::account::ddo::CCustomerCreditDdo& oCustomerCreditDdo,
		 const std::string& strInReserve,
		 std::string& strErrmsg,
		 std::string& strOutReserve
		);

	 /**
	 *
	 *   添加/修改联系人；传入联系人SysNo不为0时则进行修改，反之则进行添加；
	 *
	 */
	EXPORT(0xc038180b) uint32_t ModifyContact(
		 const CCntlInfo& rCntlInfo,
		 const std::string& strMachineKey,
		 const std::string& strSource,
		 uint32_t dwSceneId,
		 uint32_t dwOption,
		 const erp::account::ddo::CContactDdo& oContactDdo,
		 const std::string& strInReserve,
		 std::string& strErrmsg,
		 uint64_t& ddwSysNo,
		 std::string& strOutReserve
		);

	 /**
	 *
	 *   删除联系人（逻辑）
	 *
	 */
	EXPORT(0xc038180c) uint32_t DeleteContact(
		 const CCntlInfo& rCntlInfo,
		 const std::string& strMachineKey,
		 const std::string& strSource,
		 uint32_t dwSceneId,
		 uint32_t dwOption,
		 uint64_t ddwContactSysNo,
		 const std::string& strInReserve,
		 std::string& strErrmsg,
		 std::string& strOutReserve
		);

	 /**
	 *
	 *   根据联系人SysNo批量获取联系人信息
	 *
	 */
	EXPORT(0xc038180d) uint32_t GetContactBySysNos(
		 const CCntlInfo& rCntlInfo,
		 const std::string& strMachineKey,
		 const std::string& strSource,
		 uint32_t dwSceneId,
		 uint32_t dwOption,
		 const std::set<uint64_t> & setContactSysNo,
		 const std::string& strInReserve,
		 std::string& strErrmsg,
		 std::map<uint64_t,uint32_t> & mapErrorCode,
		 std::map<uint64_t,std::string> & mapErrorMsg,
		 std::map<uint64_t,erp::account::ddo::CContactDdo> & mapContactDdo,
		 std::string& strOutReserve
		);

	 /**
	 *
	 *   根据过滤条件查询联系人信息
	 *
	 */
	EXPORT(0xc038180e) uint32_t GetContactByFilter(
		 const CCntlInfo& rCntlInfo,
		 const std::string& strMachineKey,
		 const std::string& strSource,
		 uint32_t dwSceneId,
		 uint32_t dwOption,
		 const erp::account::ddo::CContactFilterDdo& oFilter,
		 const std::string& strInReserve,
		 std::string& strErrmsg,
		 uint32_t& dwTotal,
		 std::vector<erp::account::ddo::CContactDdo> & vecContactDdo,
		 std::string& strOutReserve
		);

SECTION_SELF_DEFINE_START
/**
* 请在这里增加自定义的成员变量和函数，否则无法合并代码
**/

private:

	uint32_t CheckCommParam(
		const CCntlInfo& rCntlInfo,
		const std::string& strMachineKey,
		const std::string& strSource,
		const uint32_t dwSceneId);

	uint32_t CheckBusinessUnitsDdo(
			const erp::account::ddo::CBusinessUnitsDdo& oBusinessUnitsDdo,
			std::string& strErrmsg);


	uint32_t CheckBusinessUnitsSysNos(
			const std::set<uint64_t> & setBusinessUnitsSysNo,
			std::string& strErrmsg);

	uint32_t CheckBusinessUnitsFilterDdo(
			const erp::account::ddo::CBusinessUnitsFilterDdo& oFilter,
			std::string& strErrmsg);

	uint32_t CheckEmployeeDdo(
			const erp::account::ddo::CEmployeeDdo& oEmployeeDdo,
			std::string& strErrmsg);

	uint32_t CheckEmployeeBySysNos(
			const std::set<uint64_t> & setEmployeeSysNo,
			std::string& strErrmsg);

	uint32_t CheckEmployeeFilterDdo(
			const erp::account::ddo::CEmployeeFilterDdo& oFilter,
			std::string& strErrmsg);

	uint32_t CheckCustomerCreditDdo(
			const erp::account::ddo::CCustomerCreditDdo& oCustomerCreditDdo,
			std::string& strErrmsg);

	uint32_t CheckContactDdo(
			 const erp::account::ddo::CContactDdo& oContactDdo,
			std::string& strErrmsg);

	uint32_t CheckContactSysNos(
			const std::set<uint64_t> & setContactSysNo,
			std::string& strErrmsg);

	uint32_t CheckContactFilterDdo(
			const erp::account::ddo::CContactFilterDdo& oFilter,
			std::string& strErrmsg);

	uint32_t GetRealSysNo(
			const CCntlInfo& rCntlInfo,
			const std::string& strMachineKey,
			const std::string& strSource,
			const uint32_t dwSceneId,
			const ERP_YUN_IDMAKER_TYPE eBizType,
			uint64_t& StartId
		);

SECTION_SELF_DEFINE_END

private:
	enum DeployMethod m_method;

	static erp::account::db::CAccountDBOperator m_oDBOperator;

	c2cent::dao::idmaker::CIdMakerDaoStub4Web m_sysNoMaker;
};

}
}
}

#endif /* _ACCOUNTDAO_ACCOUNT_H_ */
